//
//  Srting+Extension.swift
//  SwiftWB
//
//  Created by 钟清 on 17/3/30.
//  Copyright © 2017年 Zhong Qing. All rights reserved.
//

import Foundation
extension String {
    /* 快速生成缓存路径 */
    func cachesDir() -> String {
        let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true).last!
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).stringByAppendingPathComponent(name)
        return filePath
    }
    
    /* 快速生成文档路径 */
    func docDir() -> String {
        let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true).last!
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).stringByAppendingPathComponent(name)
        return filePath
    }
    
    /* 快速生成临时路径 */
    func tempDir() -> String {
        let path = NSTemporaryDirectory()
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).stringByAppendingPathComponent(name)
        return filePath
    }
}